package com.juc.phaser.phaser5;

import java.util.concurrent.Phaser;

public class Run {

	public static void main(String[] args) {
		Phaser phaser = new Phaser(2) {
			@Override
			protected boolean onAdvance(int phase, int registeredParties) {
                 System.out.println("protected boolean onAdvance(int phase, int registeredParties) 被调用 ！");
				return true;
				//返回true 不等待了 Phaser 呈无效/销毁 的状态
				//返回false 则Phaser 继续工作
			}
		};
		MyService myService = new MyService(phaser);
		ThreadA a = new ThreadA(myService);
		a.setName("A");
		a.start();
		ThreadB b = new ThreadB(myService);
		b.setName("B");
		b.start();
	}
}
